package org.linsoho.xmlupdate;

import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;

public class TableModel {

    /**
     * 选中
     */
    private BooleanProperty selected;
    
    /**
     * 票据名称
     */
    private StringProperty name;
    
    /**
     * 票据文件路径
     */
    private StringProperty path;
    
    public TableModel() {
        this.selected = new SimpleBooleanProperty(true);
        this.name = new SimpleStringProperty("");
        this.path = new SimpleStringProperty("");
        
        this.selected.addListener(new ChangeListener<Boolean>() {

            @Override
            public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
                System.out.println(nameProperty().get() + " select:" + newValue);
            }
        });
    }

    public BooleanProperty selectedProperty() {
        return selected;
    }

    public Boolean isSelected() {
        return selected.get();
    }
    
    public void setSelected(boolean selected) {
        this.selected.set(selected);;
    }

    public StringProperty nameProperty() {
        return name;
    }
    
    public String getName() {
        return name.get();
    }

    public void setName(String name) {
        this.name.set(name);
    }

    public StringProperty pathProperty() {
        return path;
    }

    public String getPath() {
        return path.get();
    }
    
    public void setPath(String path) {
        this.path.set(path);
    }

}
